<?php

if (!defined('BASEPATH'))
	exit('No direct script access allowed');

/**
 * Init Model
 *
 */


class Profile_model extends CI_Model {

	function __construct(){
		parent::__construct();
	}
	//--Get Membership--//
	function showlist() {
		$query = $this->db->get('membership');
		$result = $query->result();
		return $result;
	}
	
	function get_membership($id=0){
		$sql = "select * from membership where id= $id";
		$query = $this->db->query($sql);
		$row = $query->row();
		return $row;
	}
	function getProfile($id=0){
		$sql = "select * from profile where id = $id ";
		$result = $this->db->query($sql)->row();
		if($result) return $result;
	}
	
	function getProfileByMemberID($mem_id=null){
		$sql = "select * from profile where mem_id = $mem_id ";
		$query = $this->db->query($sql);
		if($query) return $query->row();
	}
	
	function getSpecialities(){
		$sql = "select * from category_tree where status = 51";
		$result = $this->db->query($sql)->result();
		if($result) return $result;
	}
	
	function getStates(){
		$sql = "select * from state where status = 51";
		$result = $this->db->query($sql)->result();
		if($result) return $result;
	}
	
	function get_listing_keyword($listing_id=0,$key_id=0){
		$sql = "select * from term where listing_id=$listing_id and term_value=$key_id limit 1";
		$query = $this->db->query($sql);
		if($query->num_rows()!=0){
			return $query->row()->term_value;
		}else{
			return 0;
		}
	}

	function getPayment($listing_id=0,$key_id=0){
		$sql = "select * from term where listing_id=$listing_id and term_value=$key_id and status = 51";
		$result = $this->db->query($sql)->result();
		if($result) return $result;
	}
	
	function getSale($mem_id)
	{
		$sql = "select * from sale where mem_id = $mem_id";
		$result = $this->db->query($sql)->result();
		if($result) return $result;
	}
	
}